package com.syxbyi._3game;

import java.util.Map;

public enum Rank {
    JOKER(15, "大王"),
    BLACK(14, "小王"),
    TWO(13, "2"),           // 这里value值只用来排序，因为扑克中2比A比K大，因此安排了value=13
    ACE(12, "A"),
    KING(11, "K"),
    QUEEN(10, "Q"),
    JACK(9, "J"),
    TEN(8, "10"),
    NINE(7, "9"),
    EIGHT(6, "8"),
    SEVEN(5, "7"),
    SIX(4, "6"),
    FIVE(3, "5"),
    FOUR(2, "4"),
    THREE(1, "3");


    private int value;
    private String name;

    Rank(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public static Rank valueOf(int i) {
        switch (i) {
            case 1:
                return Rank.ACE;
            case 2:
                return Rank.TWO;
            case 3:
                return Rank.THREE;
            case 4:
                return Rank.FOUR;
            case 5:
                return Rank.FIVE;
            case 6:
                return Rank.SIX;
            case 7:
                return Rank.SEVEN;
            case 8:
                return Rank.EIGHT;
            case 9:
                return Rank.NINE;
            case 10:
                return Rank.TEN;
            case 11:
                return Rank.JACK;
            case 12:
                return Rank.QUEEN;
            case 13:
                return Rank.KING;
            case 14:
                return Rank.BLACK;
            case 15:
                return Rank.JOKER;
            default:
                return null;
        }
    }

    public static int getValue(Rank r) {
        return r.value;
    }

    public static String toString(Rank r) {
        return r.name;
    }
}
